package com.slz3.business.module.systemManagement.sysMenu.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.systemManagement.sysMenu.domain.SysMenu;
import com.slz3.business.module.systemManagement.sysMenu.domain.SysMenuCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class SysMenuResController {

    @Resource
    private SysMenuResAtomic sysMenuResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, SysMenu sysMenu) {
        if (SysMenuResUnsafeValid.add(req, sysMenu)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.add_$SysMenuUpdateLock(req, sysMenu);
        }
    }

    public  Mono<ServerResponse> delete(ServerRequest req, SysMenuCondition sysMenuCondition) {
        if (SysMenuResUnsafeValid.delete(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.delete_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, SysMenu sysMenu) {
        if (SysMenuResUnsafeValid.modify(req, sysMenu)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.modify_$SysMenuUpdateLock(req, sysMenu);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (SysMenuResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return SysMenuResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
        if (SysMenuResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.info_$SysMenuUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (SysMenuResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return SysMenuResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, SysMenuCondition sysMenuCondition) {
        //
        if (SysMenuResUnsafeValid.auditSubmit(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.auditSubmit_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, SysMenuCondition sysMenuCondition) {
        if (SysMenuResUnsafeValid.audit(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.audit_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, SysMenuCondition sysMenuCondition) {
        if (SysMenuResUnsafeValid.auditReject(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.auditReject_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public  Mono<ServerResponse> usingEnable(ServerRequest req, SysMenuCondition sysMenuCondition) {
        if (SysMenuResUnsafeValid.usingEnable(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.usingEnable_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, SysMenuCondition sysMenuCondition) {
        if (SysMenuResUnsafeValid.usingDisable(req, sysMenuCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return sysMenuResAtomic.usingDisable_$SysMenuUpdateLock(req, sysMenuCondition);
        }
    }

    public Mono<ServerResponse> listAllMenu(ServerRequest req) {
        return SysMenuResExecutor.listAllMenu(req);
    }

    public Mono<ServerResponse> listMenuByLogin(ServerRequest req) {
        return SysMenuResExecutor.listMenuByLogin(req);
    }
}
